import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
// import { userListData } from '/@/api/sys/user';
import { lxjgSelectData } from '/@/api/m8/machine/task';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('加工任务选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: 'selIds',
      field: 'selIds',
      component: 'Input',
      show: false,
    },
    {
      label: 'lxjgKey',
      field: 'lxjgKey',
      component: 'Input',
      show: false,
    },
    {
      label: t('任务'),
      field: 'taskCode',
      component: 'Input',
    },
    {
      label: t('图号'),
      field: 'orderPic.picno',
      component: 'Input',
    },
    {
      label: t('图名'),
      field: 'orderPic.picname',
      component: 'Input',
    },
    {
      label: t('工序'),
      field: 'oper.operName',
      component: 'Input',
    },
    {
      label: t('任务状态'),
      field: 'taskStatus',
      component: 'Select',
      componentProps: {
        dictType: 'm8_task_status',
        allowClear: true,
      },
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('任务'),
    dataIndex: 'taskCode',
    key: 'a.task_code',
    sorter: true,
    width: 120,
    slot: 'firstColumn',
  },
  {
    title: t('任务状态'),
    dataIndex: 'taskStatus',
    key: 'a.task_status',
    sorter: true,
    width: 100,
    dictType: 'm8_task_status',
  },
  {
    title: t('图号'),
    dataIndex: 'orderPic.picno',
    key: 'pic.picno',
    sorter: true,
    width: 120,
  },
  {
    title: t('图名'),
    dataIndex: 'orderPic.picname',
    key: 'pic.picname',
    sorter: true,
    width: 200,
  },
  {
    title: t('加工顺序'),
    dataIndex: 'sortNum',
    key: 'a.sort_num',
    sorter: true,
    width: 80,
  },
  {
    title: t('优先级'),
    dataIndex: 'firstLevel',
    key: 'a.first_level',
    sorter: true,
    width: 100,
  },
  {
    title: t('数量'),
    dataIndex: 'iqty',
    key: 'a.iqty',
    sorter: true,
    width: 100,
  },
  {
    title: t('计划开始'),
    dataIndex: 'planBeginDate',
    key: 'a.plan_begin_date',
    sorter: true,
    width: 100,
  },
  {
    title: t('计划截止'),
    dataIndex: 'planEndDate',
    key: 'a.plan_end_date',
    sorter: true,
    width: 100,
  },
  {
    title: t('加工'),
    dataIndex: 'jgtime',
    key: 'a.jgtime',
    sorter: true,
    width: 100,
  },
  {
    title: t('调试'),
    dataIndex: 'tstime',
    key: 'a.tstime',
    sorter: true,
    width: 100,
  },
];

const tableProps: BasicTableProps = {
  api: lxjgSelectData,
  beforeFetch: (params) => {
    console.log(params);

    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'taskCode',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'taskCode',
  itemName: 'taskCode',
};
